<?php
namespace App\Models\Scripts;

use Illuminate\Support\Facades\DB;

class v9aec6538d7fa57bc122c18d0c5f266e1 extends Sysupdate
{
    protected $version_id ='VUE-0211'; //修改了member_source、admin_users_extend 和 config表  。命令：php artisan cmd:runscripts --v=VUE-0211

    private $returnData = array('code'=>0,'message'=>'执行成功');

    public function upgrade()
    {
        try {
            $r_data = $this->_step_1();
            if (!$r_data) {
                return $r_data;
            }
        }catch (\Exception $e){}
        try {
            $r_data = $this->_step_2();
            if(!$r_data){
                return $r_data;
            }
        }catch (\Exception $e){}

        try {
            $r_data = $this->_step_3();
            if(!$r_data){
                return $r_data;
            }
        }catch (\Exception $e){}

        try {
            $r_data = $this->_step_4();
            if(!$r_data){
                return $r_data;
            }
        }catch (\Exception $e){}
        return $this->returnData;
    }

    private function _step_1()
    {
        $sql = "alter table configs add `seo_title` varchar(255) DEFAULT NULL COMMENT '网站seo的标题';";
        DB::statement($sql);
        return $this->returnData;
    }

    private function _step_2()
    {
        $sql = "alter table member_source add `order` int(10) DEFAULT 0 COMMENT '排序，越大越靠前';";
        DB::statement($sql);
        return $this->returnData;
    }

    private function _step_3()
    {
        $sql = "alter table admin_users_extend add `identity_card_pic` varchar(500) NOT NULL COMMENT '身份证正反面图片';";
        DB::statement($sql);
        $sql = "alter table admin_users_extend add `certificate_pic` text NOT NULL COMMENT '证书图片';";
        DB::statement($sql);
        $sql = "alter table admin_users_extend add `examination_pic` text NOT NULL COMMENT '体检图片';";
        DB::statement($sql);
        $sql = "alter table admin_users_extend add `other_pic` text NOT NULL COMMENT '其它图片';";
        DB::statement($sql);
        return $this->returnData;
    }

    private function _step_4()
    {
        $sql = "alter table admin_users_extend add `real_avatar` varchar(255) NOT NULL COMMENT '';";
        DB::statement($sql);
        return $this->returnData;
    }
}
